package com.janko.springbootbase.designmode.observer.v1thread;

/**
 * @Description 类文件说明
 * @Author nieyankang
 * @Version 1.0
 * @date {date} {time}
 */
public class Client {
    /**
     * 这种太耗费内存了、要一直跑着线程，还有两个 volatile 要占用较大CPU
     */
    public static void main(String[] args)  throws InterruptedException{
        //定义出韩非子和李斯
        LiSi liSi = new LiSi();
        HanFeiZi hanFeiZi = new HanFeiZi();

        //观察早餐
        Watch watchBreakfast = new Watch(hanFeiZi,liSi,"breakfast");
        //开始启动线程，监控
        watchBreakfast.start();
        //观察娱乐情况
        Watch watchFun = new Watch(hanFeiZi,liSi,"fun");
        watchFun.start();


        //然后韩非子开始办事儿了
        Thread.sleep(2000); //主线程等待1秒后后再往下执行
        hanFeiZi.haveBreakfast();

        //韩非子娱乐了
        Thread.sleep(1000);
        hanFeiZi.haveFun();
    }
}
